﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace JC_DirectBroadcast.Repository.Interface
{
    public interface IRepository<TEntity> where TEntity : class, new()
    {
        TEntity GetById(object key);

        bool IsExist(Expression<Func<TEntity, bool>> wherExpression);

        TEntity GetSingle(Expression<Func<TEntity, bool>> wherExpression);

        List<TEntity> GetPageList(Expression<Func<TEntity, bool>> whereExpression, PageModel page,
            Expression<Func<TEntity, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);

        List<TEntity> GetList(Expression<Func<TEntity, bool>> whereExpression = null);

        int Count(Expression<Func<TEntity, bool>> whereExpression);

        bool Insert(TEntity entity);

        int InsertReturnIdentity(TEntity entity);

        //bool InsertRange(TEntity[] entities);

        bool InsertRange(List<TEntity> entities);

        bool Update(TEntity entity);

        bool UpdateRange(TEntity[] entities);

        bool UpdateRange(List<TEntity> entities);

        bool Update(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> whereExpression);

        bool Delete(TEntity entity);

        bool Delete(Expression<Func<TEntity, bool>> whereExpression);

        bool DeleteById(object id);

        //bool DeleteByIds(object[] ids);
    }
}
